<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
 <head>
  <title>inputEx - CheckBox Usage</title>

<!-- YUI CSS -->
<link rel="stylesheet" type="text/css" href="../lib/yui/reset-fonts/reset-fonts.css">
<link rel="stylesheet" type="text/css" href="../lib/yui/container/assets/container.css"> 
<link rel="stylesheet" type="text/css" href="../lib/yui/assets/skins/sam/skin.css">

<!-- InputEx CSS -->
<link type='text/css' rel='stylesheet' href='../css/inputEx.css' />

<!-- Demo CSS -->
<link rel="stylesheet" type="text/css" href="css/demo.css"/>
<link rel="stylesheet" type="text/css" href="css/dpSyntaxHighlighter.css">

 </head>

 <body>

<h1>inputEx - CheckBox Usage</h1>


<!-- Example 1 -->
<div class='exampleDiv'>
	<h2>Basic CheckBox creation</h2>
	<p>Use the following code to create a basic inputEx CheckBox.</p>
	<div class='demoContainer' id='container1'></div>
	<div class='codeContainer'>
		<textarea name="code" class="JScript">
			new inputEx.CheckBox({parentEl: 'container1'});
		</textarea>
	</div>
</div>


<!-- Example 2 -->
<div class='exampleDiv'>
	<h2>With a label</h2>
	<p>Add the label</p>
	<div class='demoContainer' id='container2'></div>
	<div class='codeContainer'>
		<textarea name="code" class="JScript">
			new inputEx.CheckBox({label: 'Do you like inputEx ?', rightLabel: 'Check me !', parentEl: 'container2', value: false});
		</textarea>
	</div>
</div>


<!-- Example 3 -->
<div class='exampleDiv'>
	<h2>Default returned values</h2>
	<p>In its simplest form, the CheckBox returns <i>true</i> if checked, <i>false</i> otherwise.</p>
	<div class='demoContainer' id='container3'></div>
	<div class='codeContainer'>
		<textarea name="code" class="JScript">
			var exampleDiv = YAHOO.util.Dom.get('container3');
			var field1 = new inputEx.CheckBox({rightLabel: 'I return true/false', parentEl: exampleDiv});
			var button = inputEx.cn('button', null, null, 'getValue()');
			exampleDiv.appendChild(button); 
			YAHOO.util.Event.addListener(button, 'click', function() { alert(field1.getValue()); });
		</textarea>
	</div>
</div>


<!-- Example 4 -->
<div class='exampleDiv'>
	<h2>Changing the returned values</h2>
	<p>You can return different values if needed.</p>
	<div class='demoContainer' id='container4'></div>
	<div class='codeContainer'>
		<textarea name="code" class="JScript">
			var exampleDiv = YAHOO.util.Dom.get('container4');
			var field2 = new inputEx.CheckBox({sentValues: ['Yes', 'No'], rightLabel: 'Do you agree ?', parentEl: exampleDiv, value: 'Yes'});
			var button = inputEx.cn('button', null, null, 'getValue()');
			var button2 = inputEx.cn('button', null, null, 'setValue("No")');
			var button3 = inputEx.cn('button', null, null, 'setValue("Yes")');
			exampleDiv.appendChild(button); 
			exampleDiv.appendChild(button2); 
			exampleDiv.appendChild(button3); 
			YAHOO.util.Event.addListener(button, 'click', function() { alert(field2.getValue()); });
			YAHOO.util.Event.addListener(button2, 'click', function() { field2.setValue('No'); });
			YAHOO.util.Event.addListener(button3, 'click', function() { field2.setValue('Yes'); });
		</textarea>
	</div>
</div>



<!-- Example 5 -->
<div class='exampleDiv'>
	<h2>Updated event</h2>
	<p>How to listen to the updated event :</p>
	<div class='demoContainer' id='container5'></div>
	<div class='codeContainer'>
		<textarea name="code" class="JScript" cols="60" rows="1">
			var el = YAHOO.util.Dom.get('container5');
			var field = new inputEx.CheckBox({parentEl: el });
			var logDiv = inputEx.cn('div', null, null, "Log :");
			el.appendChild(logDiv);
			field.updatedEvt.subscribe(function() {
				logDiv.innerHTML += "Updated at "+(new Date())+" with value : "+field.getValue();
				logDiv.appendChild(inputEx.cn('br'));
			});
		</textarea>
	</div>
</div>



<!-- Example 6 -->
<div class='exampleDiv'>
	<h2>Disabling checkboxes</h2>
	<p>How to enable/disable a checkbox :</p>
	<div class='demoContainer' id='container6'></div>
	<div class='codeContainer'>
		<textarea name="code" class="JScript" cols="60" rows="1">
					var dc = new inputEx.CheckBox({label: 'Disable', parentEl: 'container6'});
					dc.disable();
		</textarea>
	</div>
</div>


<!-- YUI Library -->
<script type="text/javascript" src="../lib/yui/utilities/utilities.js"></script>

<!-- InputEx -->
<script src="../js/inputex.js"  type='text/javascript'></script>
<script src="../js/Field.js"  type='text/javascript'></script>
<script src="../js/fields/CheckBox.js"  type='text/javascript'></script>

<!-- inputEx examples -->
<script src="js/dpSyntaxHighlighter.js"></script>
<script src="inputex-examples.js"></script>

 </body>
</html>